import {Component} from 'react'
import {Menu} from "antd";
import {inject,observer} from 'mobx-react'
import {Link} from 'react-router-dom'
import * as icons from "@ant-design/icons";
const { SubMenu } = Menu;
@inject('login')
@observer
class Newlist extends Component{
    bindMenu(gongnengInfo){
        let menuarr =gongnengInfo.map((item,index)=>{
            // let lconMenu =icons[item.menuImgClass];
            if (item.childrens && item.childrens.length>0){
                return <SubMenu key={item.menuId}  title={item.menuName}>
                    {this.bindMenu(item.childrens)}
                </SubMenu>
            }else {
                return<Menu.Item key={item.menuId}>
                    <Link to={item.menuUrl}>{item.menuName}</Link>
                </Menu.Item>
            }
        })
        return menuarr;
    }
    render() {
        return (
            <Menu
                style={{ width: 256 }}
                defaultSelectedKeys={['1']}
                defaultOpenKeys={['sub1']}
                mode="inline"
            >
                {this.bindMenu(this.props.login.gongnengInfo)}
            </Menu>
        )
    }
}
export {Newlist as default}